﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Conusic.Model.Audio.Server
{
    public static class ContentType
    {
        private const string DefaultContentType = "application/octet-stream";
        private static Dictionary<string, string> associations;
        
        private static void FillAssociation()
        {
            associations = new Dictionary<string, string>
                               {
                                   {".htm", "text/html"},
                                   {".html", "text/html"},
                                   {".txt", "text/plain"},
                                   {".js", "application/x-javascript"},
                                   {".css", "text/css"},
                                   {".jpg", "image/jpeg"},
                                   {".jpeg", "image/jpeg"}
                               };
        }
    
        public static string GetContentType(string extension)
        {
            if(associations==null) FillAssociation();

            if (associations.ContainsKey(extension))
                return associations[extension];
            else
            {
                return DefaultContentType;
            }
        }
    }
}
